const i18nExtensions = require('vue-i18n-extensions')
module.exports = {
    /*
     ** Headers of the page
     */
    head: {
        title: 'nuxt-vue-pro',
        meta: [{
                charset: 'utf-8'
            },
            {
                name: 'viewport',
                content: 'width=device-width, initial-scale=1'
            },
            {
                hid: 'description',
                name: 'description',
                content: 'Nuxt.js project'
            }
        ],
        link: [{
            rel: 'icon',
            type: 'image/x-icon',
            href: '/favicon.ico'
        }],
        css: [{
                src: '~assets/css/normailze.css'
            },
            {
                src: 'iview/dist/styles/iview.css'
            }
        ]
    },
    /*
     ** Customize the progress bar color
     */
    // loading组件
    // loading: '~components/loading.vue'
    loading: {
        color: '#3B8070'
    },
    /*
     ** Build configuration
     */
    build: {
        loaders: [
            /**
             * 
             */
            {
                test: /\.(png|jpe?g|gif|svg)$/,
                loader: "url-loader",
                query: {
                    limit: 10000,
                    name: 'img/[name].[hash].[ext]'
                }
            },
            {
                test: /\.less$/,
                loader: "style-loader!css-loader!less-loader",
            }
        ],
        /**
         * 打包后vender文件：element-ui axios
         */
        // , 'element-ui'
        vendor: ['axios', 'vue-i18n'],
        /**
         * 按需加载
         */
        babel: {
            plugins: [
                //   [
                //     'component', [{
                //         'libraryName': 'element-ui',
                //         'styleLibraryName': 'theme-chalk'
                //       },
                //       'transform-async-to-generator',
                //       'transform-runtime'
                //     ]
                //   ]
            ],
            // comments: false
        },
        /*
         ** Run ESLint on save
         */
        extend(config, {
            isDev,
            isClient
        }) {
            config.module.rules.push({
                test: /\.vue$/,
                loader: 'iview-loader',
                options: {
                    prefix: false
                }
            })
            if (isDev && isClient) {
                config.module.rules.push({
                    enforce: 'pre',
                    test: /\.(js|vue)$/,
                    loader: 'eslint-loader',
                    exclude: /(node_modules)/
                })

            }
        }
    },
    render: {
        bundleRenderer: {
            directives: {
                t: i18nExtensions.directive
            }
        }
    },
    plugins: [{
            src: '~plugins/element-ui',
            ssr: false
        },
        {
            src: '~plugins/iview',
            ssr: true
        },
        {
            src: '~plugins/i18n',
            ssr: true
        }
    ],
    router: {
        extendRoutes(routes, resolve) {
            // routes.push({
            //   name: 'category-home',
            //   path: '/:city-:category/:filter?',
            //   component: resolve(__dirname, 'nuxt/pages/activity/category-home.html.vue')
            // })
        },
        middleware: 'auth'
    }
}
